home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / code_gen / vbcodwiz / vbcwur.exe / VBCWUR.ZIP / VBCODE1.DB_ / VBCODE1.DB
Encoding:
INI File  |  1995-05-01  |  1.4 KB  |  59 lines

  1. [1]
  2. CenterForm centers the form passed to it horizontally and vertically on the screen. 
  3. [Code]
  4. Sub CenterForm (F As Form)
  5. F.Left = (Screen.Width - F.Width) / 2
  6. F.Top = (Screen.Height - F.Height) / 2
  7. End Sub
  8. [Stop]
  9. [2]
  10. DblClick Event Example
  11. [Code]
  12. The example displays a selected list item in a text box when either a command button is clicked or
  13. a list item is double-clicked.  To try this example, paste the code into the Declarations section of a 
  14. form that contains list box, a text box and a command button.  Then press F5 and click the 
  15. command button or double click a list box item.
  16.  
  17. Sub Form_Load ()
  18.     List1.AddItem "John"    ' Add list box entries.
  19.     List1.AddItem "Paul"
  20.     List1.AddItem "George"
  21.     List1.AddItem "Ringo"
  22. End Sub
  23.  
  24.  
  25.  
  26. Sub List1_DblClick ()
  27.     Command1.Value = True    ' Trigger Click event.
  28. End Sub
  29.  
  30.  
  31.  
  32. Sub Command1_Click ()
  33.     Text1.Text = List1.Text    ' Display selection.
  34. End Sub
  35.  
  36.  
  37.  
  38. [Stop]
  39. [3]
  40. ActiveControl Property Example 1
  41.  
  42.  
  43. [Code]
  44. The example displays the text of the active control.  To try this example, paste the code into the
  45. Declarations section of a form that contains a text box, a label, and a command button.  Then press F5 
  46. and click the form.
  47. Sub Form_Click ()
  48.     If TypeOf Screen.ActiveControl Is TextBox Then
  49.         Label1.Caption = Screen.ActiveControl.Text
  50.     Else
  51.         Label1.Caption = "Button: " + Screen.ActiveControl.Caption
  52.     End If
  53. End Sub
  54.  
  55.  
  56.  
  57.  
  58. [Stop]
  59.